<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/10/17 0017
  Time: 上午 10:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>客户登记</title>
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/common.css">
    <style>
        .company{
            display: none;
        }
        .box-padding-15{
            margin: 20px;
        }
    </style>
</head>
<body>

<div class="box-padding-15">
         <span class="layui-breadcrumb">
          <a href="#">首页</a>
          <a href="javascript:;">我要租车</a>
          <a><cite>客户登记</cite></a>
        </span>
    <hr>
    <div class="box-form">
        <form class="layui-form " action="/client/save" method="post"  id="formid">





            <div class="layui-form-item">
                <label class="layui-form-label">客户手机：</label>
                <div class="layui-input-block">
                    <input type="text" name="mobile" required  lay-verify="required|mobile" placeholder="请输入手机" autocomplete="off" class="layui-input">
                </div>
            </div>



            <div class="layui-form-item">
                <label class="layui-form-label">客户姓名：</label>
                <div class="layui-input-block">
                    <input type="text" name="name" required  lay-verify="required|name" placeholder="请输入客户姓名" autocomplete="off" class="layui-input">
                </div>
            </div>







            <div id="idCard" class="layui-form-item ">
                <label class="layui-form-label">身份证号：</label>
                <div class="layui-input-block">
                    <input type="text" name="idCard"  required  lay-verify="required|mail" placeholder="请输入身份证号" autocomplete="off" class="layui-input">
                </div>
            </div>



            <div  class="layui-form-item ">
                <label class="layui-form-label">驾驶证号：</label>
                <div class="layui-input-block">
                    <input type="text" name="driverNum"  required  lay-verify="required|driverNum" placeholder="请输入驾驶证号" autocomplete="off" class="layui-input"/>
                </div>
            </div>


            <div class="layui-form-item" >
                <label class="layui-form-label">我是企业</label>
                <div class="layui-input-block" onclick="showCompany()">
                    <input type="checkbox" name="like[write]" id="checkbox-id"/>
                </div>
            </div>





            <div class="layui-form-item company">
                <label class="layui-form-label">营业执照</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="upload">上传照片</button>
                        <input type="hidden"  name="busilicense" id="busiLicense">
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" STYLE="width: 100px;height: 100px"  id="demo1"/>
                            <p id="uploadMsg" ></p>
                        </div>
                    </div>
                </div>
            </div>







            <div  class="layui-form-item company " >
                <label class="layui-form-label">机构代码：</label>
                <div class="layui-input-block">
                    <input type="text" name="orgcode"    lay-verify="mail" placeholder="请输入机构代码" autocomplete="off" class="layui-input">
                </div>
            </div>



            <div  class="layui-form-item company " >
                <label class="layui-form-label">税务证号：</label>
                <div class="layui-input-block">
                    <input type="text" name="taxCerton"    lay-verify="mail" placeholder="请输入税务证号" autocomplete="off" class="layui-input">
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-input-block">
                 <button class="layui-btn" lay-submit lay-filter="formSubmit" >下一步</button>
                </div>
            </div>
        </form>
    </div>

</div>


<script src="/static/plugins/jquery.js"></script>
<script src="/static/plugins/layui/layui.js"></script>
<script>



   layui.use(['upload','laydate','element','layer','form'], function() {
         var $ = layui.jquery
                , upload = layui.upload
                ,laydate = layui.laydate
                ,form = layui.form
                ,element = layui.element
                ,layer = layui.layer;



           /* //监听提交
            form.on('submit(formSubmit)', function(data){
                $.ajax({
                    url:"/rent/save",
                    date: $('#formid').serialize(),//提交整个表单
                    dataType:"json",
                    success:function (data) {

                    }


                })*/
             /*   layer.msg(JSON.stringify(data.field));
                return false;*/





            //普通图片上传
            var uploadInst = upload.render({
                elem: '#upload'
                , url: '/upload'
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    //上传成功
                    if (res.code == 1){
                        $("#busiLicense").val(res.data[0]);
                    }
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                 });
            }
         });


         form.verify({
          name: function(value, item){ //value：表单的值、item：表单的DOM对象
              if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                  return '用户名不能有特殊字符';
              }
              if(/(^\_)|(\__)|(\_+$)/.test(value)){
                  return '用户名首尾不能出现下划线\'_\'';
              }
              if(/^\d+\d+\d$/.test(value)){
                  return '用户名不能全为数字';
              }

          }
            });

   });




         function showCompany() {
                  if ($('#checkbox-id').prop('checked')) {
                      $(".company").show();
                  }else {
                      $(".company").hide();
                  }
              }

</script>
</body>
</html>

